package com.kinyx.framework.reflect;

import org.junit.Assert;
import org.junit.Test;

import lombok.AllArgsConstructor;

public class KBeanUtils_Tester_copyProperties {

	@AllArgsConstructor
	private static class B {
		private String str;

		@Override
		public String toString() { return this.str; }
	}

	private static class X {
		private B bean;
	}
	private static class Y {
		private B bean;
	}
	private static class Z {
		private String bean;
	}

	@Test
	public void test11() {
		final X from = new X();
		Assert.assertNull(from.bean);

		final Y to = new Y();
		KBeanUtils.copyProperties(from, to);
		Assert.assertNull(to.bean);
	}

	@Test
	public void test12() {
		final X from = new X();
		Assert.assertNull(from.bean);
		from.bean = new B("str");
		Assert.assertNotNull(from.bean);

		final Y to = new Y();
		KBeanUtils.copyProperties(from, to);
		Assert.assertNotNull(to.bean);
		Assert.assertTrue(to.bean.str.equals("str"));
	}

	@Test
	public void test21() {
		final X from = new X();
		Assert.assertNull(from.bean);

		final Z to = new Z();
		KBeanUtils.copyProperties(from, to);
		Assert.assertNull(to.bean);
	}

	@Test
	public void test22() {
		final X from = new X();
		Assert.assertNull(from.bean);
		from.bean = new B("str");
		Assert.assertNotNull(from.bean);

		final Z to = new Z();
		KBeanUtils.copyProperties(from, to);
		Assert.assertNotNull(to.bean);
		Assert.assertTrue(to.bean.equals("str"));
	}

}
